<?php


namespace Yeepay\Yop\Sdk\Service\TravelResources;


use PHPUnit\Framework\TestCase;
use Yeepay\Yop\Sdk\Config\AppSdkConfig;
use Yeepay\Yop\Sdk\Exception\YopClientException;
use Yeepay\Yop\Sdk\Service\TravelResources\Model as Model;

class TravelResourcesClientTest extends TestCase
{

    private static $client;

    public static function setUpBeforeClass()
    {
        // 常用以下两种方式构造client，根据自身情况选择其一
        // 1. 基于本地配置文件方式：支持绝对路径、相对路径(相对于根目录)，适用于将文件打包到项目中，一起部署
        $sdkConfigFile = "yop_sdk_config_default.json";
        self::$client = TravelResourcesClientBuilder::builder($sdkConfigFile)->build();

        // 2. 基于json串方式：适用于自定义配置来源，从其他存储加载(比如说数据库、配置中心等)
        //$sdkConfigJson = '{"app_key":"app_xxx","server_root":"https://openapi.yeepay.com/yop-center","yos_server_root":"https://yos.yeepay.com/yop-center","yop_public_key":[{"store_type":"string","cert_type":"RSA2048","value":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6p0XWjscY+gsyqKRhw9MeLsEmhFdBRhT2emOck/F1Omw38ZWhJxh9kDfs5HzFJMrVozgU+SJFDONxs8UB0wMILKRmqfLcfClG9MyCNuJkkfm0HFQv1hRGdOvZPXj3Bckuwa7FrEXBRYUhK7vJ40afumspthmse6bs6mZxNn/mALZ2X07uznOrrc2rk41Y2HftduxZw6T4EmtWuN2x4CZ8gwSyPAW5ZzZJLQ6tZDojBK4GZTAGhnn3bg5bBsBlw2+FLkCQBuDsJVsFPiGh/b6K/+zGTvWyUcu+LUj2MejYQELDO3i2vQXVDk7lVi2/TcUYefvIcssnzsfCfjaorxsuwIDAQAB"}],"isv_private_key":[{"store_type":"string","cert_type":"RSA2048","value":"MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCf0qRvP2OJQEONEHiO5Jh2tbGo6pA3Wh7cINgpKZHLHIygZHhB4sU/2JxHqbraRsuBzC2aeWCTrXJVKjQS91vn0JHJd4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Fx+MKD2mv6j7d1KCCZQ9VLaU1ur2+I/erAS+QmIH3MKpmJAoGAP15kpYMr/tE7ENgdH64tFAHp0uWa1kuRrx6JtrnEXXerGlgIeOgT/2fRrxZ0LK7sH9UMF5qRn+MLmIUoJYvA89iWBPrpdNDc9douO1XBu62xXxpUnRy9vQnwKpN4n/pmLa67PwXPbwFna2spQ/z1y1tj0S/yND9SB1qhXGBkhy0CgYBhJf0SZ9PWaasOxAsDgFsj3mSjfvoTqclRDKo1d0KFyOIKOkK3hS8ZaHA/dcR024ydc6b0mU+pyrm2/k+JuX4dHO1M9wshS1YAXytj5RCs+43ghJrbDeNxrNK4VesJPpyK0kEGHSLbMgHnSVZ4/jAgdoKEhz1cHbZorQ92XgDzBw=="}],"encrypt_key":"AWXI5fZGXmTFVHfjyzBMMrrk1IF9dCqGJt3JIZrKY90=","http_client":{"connect_timeout":3000,"read_timeout":30000,"max_conn_total":200,"max_conn_per_route":100}}';
        //self::$client = TravelResourcesClientBuilder::builder(new AppSdkConfig(\GuzzleHttp\json_decode($sdkConfigJson, true)))->build();
    }

    /**
     * 创建电影票订单(/rest/v1.0/travel-resources/create-order)
     *
     * @test
     */
    public function createOrderTest()
    {
        $request = new Model\CreateOrderRequest();

        $request->setBody(new \Yeepay\Yop\Sdk\Service\TravelResources\Model\CinemaOrderRequestDTO());
        try{
            $response = self::$client->createOrder($request);
            print_r($response->getResult());
        }catch (\Exception $e) {
            echo 'Exception when calling TravelResourcesClient->createOrder: ', $e->getMessage(), PHP_EOL;
        }
    }
    /**
     * 申请采购订单退款(/rest/v1.0/travel-resources/create-refund-order)
     *
     * @test
     */
    public function createRefundOrderTest()
    {
        $request = new Model\CreateRefundOrderRequest();

        $request->setBody(new \Yeepay\Yop\Sdk\Service\TravelResources\Model\RefundOrderRequestDTO());
        try{
            $response = self::$client->createRefundOrder($request);
            print_r($response->getResult());
        }catch (\Exception $e) {
            echo 'Exception when calling TravelResourcesClient->createRefundOrder: ', $e->getMessage(), PHP_EOL;
        }
    }
    /**
     * 创建KFC订单(/rest/v1.0/travel-resources/kfc-order)
     *
     * @test
     */
    public function kfcOrderTest()
    {
        $request = new Model\KfcOrderRequest();

        $request->setBody(new \Yeepay\Yop\Sdk\Service\TravelResources\Model\KfcOrderRequestDTO());
        try{
            $response = self::$client->kfcOrder($request);
            print_r($response->getResult());
        }catch (\Exception $e) {
            echo 'Exception when calling TravelResourcesClient->kfcOrder: ', $e->getMessage(), PHP_EOL;
        }
    }
    /**
     * 创建KFC订单(/rest/v1.0/travel-resources/kfc-order)
     *
     * @test
     */
    public function kfcOrder_0Test()
    {
        $request = new Model\KfcOrder0Request();

        $request->setBody(new \Yeepay\Yop\Sdk\Service\TravelResources\Model\KfcOrderRequestDTO());
        try{
            $response = self::$client->kfcOrder_0($request);
            print_r($response->getResult());
        }catch (\Exception $e) {
            echo 'Exception when calling TravelResourcesClient->kfcOrder_0: ', $e->getMessage(), PHP_EOL;
        }
    }
    /**
     * 查询电影票订单(/rest/v1.0/travel-resources/query-cinema-order)
     *
     * @test
     */
    public function queryCinemaOrderTest()
    {
        $request = new Model\QueryCinemaOrderRequest();

        $request->setBody(new \Yeepay\Yop\Sdk\Service\TravelResources\Model\QueryOrderRequestDTO());
        try{
            $response = self::$client->queryCinemaOrder($request);
            print_r($response->getResult());
        }catch (\Exception $e) {
            echo 'Exception when calling TravelResourcesClient->queryCinemaOrder: ', $e->getMessage(), PHP_EOL;
        }
    }
    /**
     * 查询KFC订单(/rest/v1.0/travel-resources/query-kfc-order)
     *
     * @test
     */
    public function queryKfcOrderTest()
    {
        $request = new Model\QueryKfcOrderRequest();

        $request->setBody(new \Yeepay\Yop\Sdk\Service\TravelResources\Model\QueryOrderRequestDTO());
        try{
            $response = self::$client->queryKfcOrder($request);
            print_r($response->getResult());
        }catch (\Exception $e) {
            echo 'Exception when calling TravelResourcesClient->queryKfcOrder: ', $e->getMessage(), PHP_EOL;
        }
    }
    /**
     * 查询电影票订单(/rest/v1.0/travel-resources/query-cinema-order)
     *
     * @test
     */
    public function queryOrderTest()
    {
        $request = new Model\QueryOrderRequest();

        $request->setBody(new \Yeepay\Yop\Sdk\Service\TravelResources\Model\QueryOrderRequestDTO());
        try{
            $response = self::$client->queryOrder($request);
            print_r($response->getResult());
        }catch (\Exception $e) {
            echo 'Exception when calling TravelResourcesClient->queryOrder: ', $e->getMessage(), PHP_EOL;
        }
    }
    /**
     * 查询支付订单信息(/rest/v1.0/travel-resources/query-pay-order)
     *
     * @test
     */
    public function queryPayOrderTest()
    {
        $request = new Model\QueryPayOrderRequest();

        $request->setBody(new \Yeepay\Yop\Sdk\Service\TravelResources\Model\SupplierQueryPayRequestDTO());
        try{
            $response = self::$client->queryPayOrder($request);
            print_r($response->getResult());
        }catch (\Exception $e) {
            echo 'Exception when calling TravelResourcesClient->queryPayOrder: ', $e->getMessage(), PHP_EOL;
        }
    }
    /**
     * 查询采购退款订单(/rest/v1.0/travel-resources/query-refund-order)
     *
     * @test
     */
    public function queryRefundOrderTest()
    {
        $request = new Model\QueryRefundOrderRequest();

        $request->setBody(new \Yeepay\Yop\Sdk\Service\TravelResources\Model\QueryRefundOrderRequestDTO());
        try{
            $response = self::$client->queryRefundOrder($request);
            print_r($response->getResult());
        }catch (\Exception $e) {
            echo 'Exception when calling TravelResourcesClient->queryRefundOrder: ', $e->getMessage(), PHP_EOL;
        }
    }
}
